package oliver.shein.generic.main;

import oliver.shein.generic.scene.Generic;
import oliver.shein.generic.service.impl.AppleGeneric;
import oliver.shein.generic.service.impl.FruitGeneric;
import org.junit.gen5.api.Test;

/**
 * @Author Oliver Wang
 * @Description
 * @Created by IntelliJ IDEA 2018.
 * @Date Create at 2018/10/29 17:06
 */
public class GenericTest {
    @Test
    public void testGeneric(){
        Generic<String> stringGeneric = new Generic<>("Shein");
        Generic<Integer> integerGeneric = new Generic<>(1234);

        System.out.println(stringGeneric.getInfo()+2);
        System.out.println(integerGeneric.getInfo()+2);

        System.out.println(stringGeneric.getClass() == integerGeneric.getClass());
    }

    @Test
    public void fruitTest(){
        AppleGeneric appleGeneric = new AppleGeneric();
        System.out.println(appleGeneric.next());

        FruitGeneric<Integer> fruitGeneric = new FruitGeneric<>(new Integer(1234));
        System.out.println(fruitGeneric.next());
        System.out.println(fruitGeneric.getClass().toGenericString());
    }

    @Test
    public void generic(){
        Generic<?> generic = new Generic<>("string");
        Generic<?> generic1 = new Generic<>(new Integer("123456"));

        Generic<String> stringGeneric = new Generic<>("string");
        Generic<Integer> integerGeneric = new Generic<>(new Integer("123456"));

        System.out.println(stringGeneric instanceof Generic<?>);
        System.out.println(integerGeneric instanceof Generic<?>);
        System.out.println(generic.getInfo());
        System.out.println(generic1.getInfo());
    }
}
